from selenium.webdriver.common.by import By

from common.Utils import FormDriver


class FormWordTest:
    Url = ""
    driver = ""
    def __init__(self):
        self.Url = "http://127.0.0.1:9580/index.html"
        self.driver = FormDriver.driver
        self.driver.get(self.Url)
    def FromWebTest(self):
        self.driver.find_element(By.CSS_SELECTOR,"#bit-forum-content > div.page-header.d-print-none > div > div > div.col-auto.ms-auto.d-print-none > div > a.btn.btn-primary.d-none.d-sm-inline-block.article_post").click()
        #Log是否存在
        self.driver.find_element(By.CSS_SELECTOR,"body > div.page > header.navbar.navbar-expand-md.navbar-light.d-print-none > div > h1 > a > img")
        #黑夜按钮
        self.driver.find_element(By.CSS_SELECTOR,"body > div.page > header.navbar.navbar-expand-md.navbar-light.d-print-none > div > div > div:nth-child(2) > a.nav-link.px-0.hide-theme-dark > svg")
        #消息按钮
        self.driver.find_element(By.CSS_SELECTOR,"body > div.page > header.navbar.navbar-expand-md.navbar-light.d-print-none > div > div > div:nth-child(2) > div > a > svg > path:nth-child(2)")
        #用户名
        self.driver.find_element(By.CSS_SELECTOR,"#index_nav_nickname")
        #模块列表
        TestList = self.driver.find_elements(By.CSS_SELECTOR,"#topBoardList")
        for i in TestList:
            print(i.text)
        #贴标题
        self.driver.find_element(By.CSS_SELECTOR,"#bit-forum-content > div.page-header.d-print-none > div > div > div > h2")
        #模块选择列表
        self.driver.find_elements(By.CSS_SELECTOR,"#article_post_borad")
        #标题输入框
        self.driver.find_element(By.CSS_SELECTOR,"#article_post_title")
        #内容输入框
        self.driver.find_element(By.CSS_SELECTOR,"#edit-article > div.CodeMirror.cm-s-default.CodeMirror-wrap.CodeMirror-empty > div.CodeMirror-scroll")
        #发布按钮
        self.driver.find_element(By.CSS_SELECTOR,"#article_post_submit")
        FormDriver.DribverScreeShot()

